package com.java.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.java.common.SessionInfo;
import com.java.control.AbstractAdminCommandController;
import com.java.control.search.CodeSearchCond;
import com.java.control.search.OrderSearchCond;
import com.java.control.search.ProductSearchCond;
import com.java.control.search.SearchStat;
import com.java.entity.Code;
import com.java.entity.OrderForm;
import com.java.entity.Product;
import com.java.mis.UserType;
import com.java.service.CodeService;
import com.java.service.OrderService;
import com.java.service.ProductService;

/**
 * 人员管理
 * @author wqf
 * @version  Nov 24, 2011 12:00:53 PM
 */
public class OrderLeftListController extends AbstractAdminCommandController {

	public OrderLeftListController(){
		this.setCommandClass(OrderSearchCond.class);
	}	

	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		OrderSearchCond searchCond = (OrderSearchCond)command;
		SessionInfo sessionInfo = this.getSessionInfo(request);
		if(null!=sessionInfo){
			if(sessionInfo.getUserType()!=UserType.admin){
				searchCond.setUserId(sessionInfo.getUserId());
			}
		}
		ModelAndView mav=new ModelAndView(this.view);
		searchCond.setPageSize(200L);
		SearchStat searchStat = this.orderService.getSearchStat(OrderForm.class, searchCond);
		List<OrderForm> list = this.orderService.search(OrderForm.class,searchCond,"id desc");
		mav.addObject("searchStat", searchStat);
		mav.addObject("searchCond", searchCond);
		mav.addObject("orderList", list);		
		
		CodeSearchCond codeSearchCond = new CodeSearchCond();
		codeSearchCond.setCodeType("订单状态");
		List<Code> statusList = this.codeService.search(Code.class,codeSearchCond);
		mav.addObject("statusList", statusList);
		
		return mav;
		
	}
	private CodeService codeService;
	public CodeService getCodeService() {
		return codeService;
	}

	public void setCodeService(CodeService codeService) {
		this.codeService = codeService;
	}
	
	private String view;
	private OrderService orderService;
	
	public void setView(String view) {
		this.view = view;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}

}
